<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
    <title>成员管理</title>
    <script type="text/javascript" src="${ctx}/static/myJs/util.js"></script>
    <script type="text/javascript" src="${ctx}/static/myJs/volunteerController.js"></script>
    <script type="text/javascript" src="${ctx}/static/jquery/jquery.form.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("#upload").click(function () {

                alert("所做的批量处理操作没有成功,请重试");

                subForm();

            });
        });

        //-------------------form---------------------------------

        //表單的異步提交

        var options = {

            //iframe:true,

            dataType:"json", // 或'script'，不能用'json'，这种方式在三种浏览器中都不行，即回调函数不执行
            type:'post',
            contentType: "application/json; charset=utf-8",
            url: "${ctx}/volunteer/importExcel", //http://localhost:8080/SHOPcity/fileupload.jsp

            beforeSubmit:showRequest,  // pre-submit callback

            success:showResponse,

            clearForm:true

            // other available options:

            // target:'#baseInfo_iframe'   // target element(s) to be updated with server response

            //resetForm: true        // reset the form after successful submit

            // $.ajax options can be used here too, for example:

            //timeout:   3000

        };

        function subForm(){
            $("#myform").ajaxSubmit(options);
        }

        function showRequest(formData, jqForm, options) {

            var queryString = $.param(formData);

            alert('About to submit: \n\n' + queryString);

        }

        function showResponse(responseText, statusText)   {

            alert(responseText.message);

        }

    </script>


    <script type="text/javascript">
        var flag = 1;
        $(document).ready(function(){
            $("#flip_userServiceFiled").click(function(){
                if (0 == flag) {
                    $("#panel_userServiceFiled").slideUp("10");
                    flag = 1;
                } else {
                    $("#panel_userServiceFiled").slideDown("10");
                    flag = 0;
                }
            });

            $("#flip_userSkill").click(function(){
                if (0 == flag) {
                    $("#panel_userSkill").slideUp("10000");
                    flag = 1;
                } else {
                    $("#panel_userSkill").slideDown("10000");
                    flag = 0;
                }
            });

            $("#flip_userJob").click(function(){
                if (0 == flag) {
                    $("#panel_userJob").slideUp("10000");
                    flag = 1;
                } else {
                    $("#panel_userJob").slideDown("10000");
                    flag = 0;
                }
            });

        });

    </script>


</head>

<body>
<div class="content">
    <!--
    <form name="myform" id="myform"  enctype="multipart/form-data" action="${ctx}/volunteer/importExcel" method="post">
        <input type="file" name="alais" />
        <input type="file" name="file2" /> <input type="text" name="alais2" /><br />
        <input type="file" name="file3" /> <input type="text" name="alais2" /><br />
        <button type="button" id="upload">提交</button>
    </form>
    -->

    <div class="page-subcate-list">
        <div class="page-searchbox">
            <input id="name" type="text" size="20" placeholder="志愿者姓名">

            <div class="pull-right">
                <button onclick="searchByName()"><i class="fa fa-plus" aria-hidden="true"></i>查询</button>
                <button onclick="create()"><i class="fa fa-plus" aria-hidden="true"></i>新建</button>
                <button onclick="exportVolunteer()"><i class="fa fa-plus" aria-hidden="true"></i>导出</button>
                <button onclick="importVolunteer()"><i class="fa fa-plus" aria-hidden="true"></i>批量导入</button>
            </div>
        </div>

        <div class="page-subcate-item" >
            <label>服务领域</label>

            <ul class="choices">
                <div>
                <c:forEach items="${userServiceFiled}" var="skill" begin="0" end="5">
                    <li><a href="javascript:void(0);" onclick="javascript:searchByServiceFiled('${skill.name}');">${skill.name}</a></li>
                </c:forEach>
                </div>
                <div id="panel_userServiceFiled" style="display: none;">
                    <c:forEach items="${userServiceFiled}" var="skill" begin="6" end="${fn:length(userServiceFiled)}">
                        <li><a href="javascript:void(0);" onclick="javascript:searchByServiceFiled('${skill.name}');">${skill.name}</a></li>
                    </c:forEach>
                </div>
            </ul>

            <span class="more" >
                <a id="flip_userServiceFiled" href="#">更多 <i class="fa fa-angle-down" aria-hidden="true"></i></a>
            </span>
        </div>
        <div class="page-subcate-item">
            <label>专业技能</label>
            <ul>
                <c:forEach items="${userSkill}" var="skill" begin="0" end="5">
                    <li><a href="javascript:void(0);" onclick="javascript:searchBySkill('${skill.name}');">${skill.name}</a></li>
                </c:forEach>
                <div id="panel_userSkill" style="display: none;">
                    <c:forEach items="${userSkill}" var="skill" begin="6" end="${fn:length(userSkill)}">
                        <li><a href="javascript:void(0);" onclick="javascript:searchBySkill('${skill.name}');">${skill.name}</a></li>
                    </c:forEach>
                </div>
            </ul>
            <span class="more">
                <a id="flip_userSkill" href="#">更多 <i class="fa fa-angle-down" aria-hidden="true"></i></a>
            </span>
        </div>
        <div class="page-subcate-item">
            <label>职业</label>
            <ul class="choices">
                <c:forEach items="${userJob}" var="skill" begin="0" end="5">
                    <li><a href="javascript:void(0);" onclick="javascript:searchByJob('${skill.name}');">${skill.name}</a></li>
                </c:forEach>
                <div id="panel_userJob" style="display: none;">
                    <c:forEach items="${userJob}" var="skill" begin="6" end="${fn:length(userJob)}">
                        <li><a href="javascript:void(0);" onclick="javascript:searchByJob('${skill.name}');">${skill.name}</a></li>
                    </c:forEach>
                </div>
            </ul>
            <span class="more">
                <a id="flip_userJob" href="#">更多 <i class="fa fa-angle-down" aria-hidden="true"></i></a>
            </span>
        </div>
        <div class="page-subcate-item">
            <label>状态</label>
                <ul class="choices">
                    <li onclick="javascript:searchByStatus('2');"><label><input name="status" type="radio" <c:if test="${status == 2}">checked="" </c:if> value="2">正常</label></li>
                    <li onclick="javascript:searchByStatus('-98');"><label><input name="status" type="radio" <c:if test="${status == -98}">checked="" </c:if> value="-98">退出</label></li>
                    <li onclick="javascript:searchByStatus('-97');"><label><input name="status" type="radio" <c:if test="${status == -97}">checked="" </c:if> value="-97">冻结</label></li>
                </ul>
        </div>
    </div>

    <table class="table table-bordered">
        <thead>
        <tr>
            <th></th>
            <th>姓名</th>
            <th>手机</th>
            <th>性别</th>
            <th>活动数量</th>
            <th>公益时间(分钟)</th>
            <th>活动时间(分钟)</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
            <c:forEach items="${data.content}" var="item" varStatus="status">
                <tr>
                    <th scope="row">${ status.index + 1}</th>
                    <td>${item.volunteer.realName}</td>
                    <td>${item.volunteer.mobile}</td>
                    <td>${item.volunteer.sex}</td>
                    <td>${item.volunteer.acts}</td>
                    <td>${item.volunteer.vTimes}</td>
                    <td>${item.volunteer.times}</td>
                    <td align="center">
                        <a href="${ctx}/volunteer/detail/${item.volunteer.memberCode}" class="table-action">查看</a>
                        <c:if test="${item.status == 2}">
                            <c:if test="${item.role == 0}">
                                <a href="javascript:void(0);"  onclick="javascript:freeze('${item.id}','-97');" class="table-action">冻结</a>
                            </c:if>
                        </c:if>
                        <c:if test="${item.status == -97}">
                            <a href="javascript:void(0);"  onclick="javascript:freeze('${item.id}','2');" class="table-action">解冻</a>
                        </c:if>
                    </td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
    <tags:pagination page="${data}" paginationSize="5"/>

</div>
</body>
</html>
